package com.yaorange.nongjt.service.impl;

import java.util.List;
import java.util.Map;

import com.yaorange.common.utils.DateUtils;
import com.yaorange.nongjt.domain.NjtUnitConfig;
import com.yaorange.nongjt.mapper.NjtUnitConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yaorange.nongjt.mapper.NjtCertificateCountMapper;
import com.yaorange.nongjt.domain.NjtCertificateCount;
import com.yaorange.nongjt.service.INjtCertificateCountService;

/**
 * 合格证统计数据Service业务层处理
 * 
 * @author juheng
 * @date 2025-02-28
 */
@Service
public class NjtCertificateCountServiceImpl implements INjtCertificateCountService 
{
    @Autowired
    private NjtCertificateCountMapper njtCertificateCountMapper;
    @Autowired
    private NjtUnitConfigMapper njtUnitConfigMapper;

    /**
     * 查询合格证统计数据
     * 
     * @param id 合格证统计数据主键
     * @return 合格证统计数据
     */
    @Override
    public NjtCertificateCount selectNjtCertificateCountById(Long id)
    {
        return njtCertificateCountMapper.selectNjtCertificateCountById(id);
    }

    /**
     * 查询合格证统计数据列表
     * 
     * @param njtCertificateCount 合格证统计数据
     * @return 合格证统计数据
     */
    @Override
    public List<NjtCertificateCount> selectNjtCertificateCountList(NjtCertificateCount njtCertificateCount)
    {
        return njtCertificateCountMapper.selectNjtCertificateCountList(njtCertificateCount);
    }

    /**
     * 新增合格证统计数据
     * 
     * @param njtCertificateCount 合格证统计数据
     * @return 结果
     */
    @Override
    public int insertNjtCertificateCount(NjtCertificateCount njtCertificateCount)
    {
        njtCertificateCount.setCreateTime(DateUtils.getNowDate());
        return njtCertificateCountMapper.insertNjtCertificateCount(njtCertificateCount);
    }

    /**
     * 修改合格证统计数据
     * 
     * @param njtCertificateCount 合格证统计数据
     * @return 结果
     */
    @Override
    public int updateNjtCertificateCount(NjtCertificateCount njtCertificateCount)
    {
        njtCertificateCount.setUpdateTime(DateUtils.getNowDate());
        return njtCertificateCountMapper.updateNjtCertificateCount(njtCertificateCount);
    }

    /**
     * 批量删除合格证统计数据
     * 
     * @param ids 需要删除的合格证统计数据主键
     * @return 结果
     */
    @Override
    public int deleteNjtCertificateCountByIds(Long[] ids)
    {
        return njtCertificateCountMapper.deleteNjtCertificateCountByIds(ids);
    }

    /**
     * 删除合格证统计数据信息
     * 
     * @param id 合格证统计数据主键
     * @return 结果
     */
    @Override
    public int deleteNjtCertificateCountById(Long id)
    {
        return njtCertificateCountMapper.deleteNjtCertificateCountById(id);
    }

    /**
     * 查询所有年份
     * @return
     */
    @Override
    public List<String> getYearList() {
        return njtCertificateCountMapper.selectYearList();
    }

    /**
     * 获取柱状图信息
     * @param year
     * @param unitId
     * @return
     */
    @Override
    public List<Map<String, Object>> selectPrintCountList(String year, Long unitId) {
        NjtUnitConfig njtUnitConfig = njtUnitConfigMapper.selectNjtUnitConfigById(unitId);
        return njtCertificateCountMapper.selectPrintCountList(njtUnitConfig, year);
    }

    /**
     * 街道/镇合格证打印数量统计
     * @param year
     * @param unitId
     * @return
     */
    @Override
    public List<Map<String, Object>> streetStatisticsByArea(String year, Long unitId) {
        NjtUnitConfig njtUnitConfig = njtUnitConfigMapper.selectNjtUnitConfigById(unitId);

        return njtCertificateCountMapper.streetStatisticsByArea(njtUnitConfig, year);
    }
}
